Denoising by Sobolev and Total Variation Regularization
This numerical tour explores the use of variational minimization to perform denoising. It consider the Sobolev and the Total Variation regularization functional (priors).
Contents
Installing toolboxes and setting up the path.
You need to download the following files: signal toolbox and general toolbox.
You need to unzip these toolboxes in your working directory, so that you have toolbox_signal and toolbox_general in your directory.
For Scilab user: you must replace the Matlab comment '%' by its Scilab counterpart '//'.
Recommandation: You should create a text file named for instance numericaltour.sce (in Scilab) or numericaltour.m (in Matlab) to write all the Scilab/Matlab command you want to execute. Then, simply run exec('numericaltour.sce'); (in Scilab) or numericaltour; (in Matlab) to run the commands.
Execute this line only if you are using Matlab.
getd = @(p)path(p,path); % scilab users must *not* execute this
Then you can add the toolboxes to the path.
getd('toolbox_signal/'); getd('toolbox_general/');
Prior and Regularization
For a given image
R
A denoising of some noisy image
y−f
2+
J(f)If
The parameter 
0
If
).png)
N
+1)=f(
)+
f(
)−y+
GradJ(f(
))
Note that for
)
+


21+
maxf
D2J(f)

Sobolev Prior
The Sobolev image prior is a quadratic prior, i.e. an Hilbert (pseudo)-norm.
First we load a clean image.
n = 256;
name = 'hibiscus';
f0 = load_image(name,n);
f0 = rescale( sum(f0,3) );
For a smooth continuous function


f(x)
2dx Where the gradient vector at point
f(x)=
x1
f(x)
x2
f(x)
For a discrete pixelized image
RN
n
f(x)
R2
Gr = grad(f0);
One can compute the norm of gradient, 
f(x)
d = sqrt(sum3(Gr.^2,3));
Display.
clf; imageplot(Gr, strcat(['grad']), 1,2,1); imageplot(d, strcat(['|grad|']), 1,2,2);
The Sobolev norm is the (squared)
f
RN
2
sob = sum(d(:).^2);
Heat Regularization for Denoising
Heat regularization smoothes the image using a low pass filter. Increasing the value of \lambda increases the amount of smoothing.
Add some noise to the original image.
sigma = .1; y = f0 + randn(n,n)*sigma;
The solution 

(
)=y
(
)1+
S(
)whereS(
)=
.png)
2
This shows that 
Useful for later: Fourier transform of the observations.
yF = fft2(y);
Compute the Sobolev prior penalty S (rescale to [0,1]).
x = [0:n/2-1, -n/2:-1]; [Y,X] = meshgrid(x,x); S = (X.^2 + Y.^2)*(2/n)^2;
Regularization parameter:
lambda = 20;
Perform the denoising by filtering.
fSob = real( ifft2( yF ./ ( 1 + lambda*S) ) );
Display.
clf; imageplot(clamp(fSob));
Exercice 1: (the solution is exo1.m) Compute the solution for several value of 
exo1;
Display best "oracle" denoising result.
esob = snr(f0,fSob0); enoisy = snr(f0,y); clf; imageplot(clamp(y), strcat(['Noisy ' num2str(enoisy,3) 'dB']), 1,2,1); imageplot(clamp(fSob0), strcat(['Sobolev regularization ' num2str(esob,3) 'dB']), 1,2,2);
Total Variation Prior
The total variation is a Banach norm. On the contrary to the Sobolev norm, it is able to take into account step edges.
The total variation of a smooth image


f(x)
dx It is extended to non-smooth images having step discontinuities.
The total variation of an image is also equal to the total length of its level sets.
−
+
L(St(f))dt Where
x
f(x)=t
Exercice 2: (the solution is exo2.m) Compute the total variation of f0.
exo2;
The Gradient of the TV norm is

f
f

The gradient of the TV norm is not defined if at a pixel
f(x)=0
To define a gradient flow, we consider instead a smooth TV norm
(f)=

2+
f(x)
2dx This corresponds to replacing
u

2+
u
2
We display (in 1D) the smoothing of the absolute value.
u = linspace(-5,5)'; clf; subplot(2,1,1); hold('on'); plot(u, abs(u), 'b'); plot(u, sqrt(.5^2+u.^2), 'r'); title('\epsilon=1/2'); axis('square'); subplot(2,1,2); hold('on'); plot(u, abs(u), 'b'); plot(u, sqrt(1^2+u.^2), 'r'); title('\epsilon=1'); axis('square');
The Gradient of the smoothed TV norm is

f
2+
f
2.png)
When 


epsilon_list = [1e-9 1e-2 1e-1 .5]; clf; for i=1:length(epsilon_list) G = div( Gr ./ repmat( sqrt( epsilon_list(i)^2 + d.^2 ) , [1 1 2]) ); imageplot(G, strcat(['epsilon=' num2str(epsilon_list(i))]), 2,2,i); end
Total Variation Regulariation for Denoising
Total variation regularization was introduced by Rudin, Osher and Fatemi, to better respect the edge of image than linear filtering.
We set a small enough regularization parameter.
epsilon = 1e-2;
Define the regularization parameter 
lambda = .1;
The step size for diffusion should satisfy:

21+
8


In practice a larger step size can be used.
tau = 2 / ( 1 + lambda * 8 / epsilon);
Initialization of the minimization.
fTV = y;
Compute the gradient of the smoothed TV norm.
Gr = grad(fTV); d = sqrt(sum3(Gr.^2,3)); G = -div( Gr ./ repmat( sqrt( epsilon^2 + d.^2 ) , [1 1 2]) );
One step of descent.
fTV = fTV - tau*( y-fTV + lambda* G);
Exercice 3: (the solution is exo3.m) Compute the gradient descent and monitor the minimized energy.
exo3;
Exercice 4: (the solution is exo4.m) Compute the solution for several value of 


exo4;
Display best "oracle" denoising result.
etvr = snr(f0,fTV0); clf; imageplot(clamp(y), strcat(['Noisy ' num2str(enoisy,3) 'dB']), 1,2,1); imageplot(clamp(fTV0), strcat(['TV regularization ' num2str(etvr,3) 'dB']), 1,2,2);
Exercice 5: (the solution is exo5.m) Compare the TV denoising with a hard thresholding in a translation invariant tight frame of wavelets.
exo5;